import torch
import os


class Config:
    """
     AG_NEWS 文本分类任务模型配置
    """

    def __init__(self):
        # 数据集相关配置
        self.project_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
        self.dataset_dir = os.path.join(self.project_dir, 'data')
        self.train_corpus_file_paths = os.path.join(self.dataset_dir, 'train.csv')
        self.test_corpus_file_paths = os.path.join(self.dataset_dir, 'test.csv')

        self.d_model = 512
        self.batch_size = 128
        self.num_head = 8
        self.num_encoder_layers = 6
        self.dim_feedforward = 2048
        self.dim_classification = 64
        self.device = torch.device('cuda:0' if torch.cuda.is_available() else 'cpu')
        self.beta1 = 0.9
        self.beta2 = 0.98
        self.epsilon = 10e-9
        self.epochs = 1
        self.model_save_dir = os.path.join(self.project_dir, 'checkpoints')
        if not os.path.exists(self.model_save_dir):
            os.makedirs(self.model_save_dir)
        self.log_dir = os.path.join(self.project_dir, 'logs')
        self.num_class = 4
        self.min_freq = 1
        self.max_sen_len = None
        self.dropout = 0.1
        self.warmup_steps = 2000


cfg = Config()
